﻿using Abp.Domain.Entities.Auditing;
using SingleUserMall.Stores;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static SingleUserMall.Dividends.Dividend;

namespace SingleUserMall.Items
{
    /// <summary>
    /// 商品
    /// </summary>
    public class Item : FullAuditedEntity<long>, IHasStore
    {
        public virtual ICollection<ItemSpec> ItemSpecs { get; set; }
        public virtual ICollection<ItemSkuCategory> ItemSkuCategories { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        [Required, MaxLength(50)]
        public string Name { get; set; }
        /// <summary>
        /// 图片
        /// </summary>
        [MaxLength(200)]
        public string Picture { get; set; }
        /// <summary>
        /// 是否热门
        /// </summary>
        public bool IsHot { get; set; }
        /// <summary>
        /// 是否上架
        /// </summary>
        public bool IsSale { get; set; }
        /// <summary>
        /// 团购标识
        /// </summary>
        public bool IsGroup { get; set; }
        /// <summary>
        /// 团购人数
        /// </summary>
        public int GroupCount { get; set; }
        /// <summary>
        /// 商品分类id
        /// </summary>
        public long ItemCategoryId { get; set; }
        [ForeignKey("ItemCategoryId")]
        public virtual ItemCategory ItemCategory { get; set; }
        /// <summary>
        /// 推荐分类id
        /// </summary>
        public long? RecommendCategoryId { get; set; }
        /// <summary>
        /// 标签（,分隔）
        /// </summary>
        [MaxLength(50)]
        public string Tags { get; set; }

        /// <summary>
        /// 运费
        /// </summary>
        public decimal Freight { get; set; }
        /// <summary>
        /// 包装费
        /// </summary>
        public decimal PackPrice { get; set; }
        /// <summary>
        /// 商品详情
        /// </summary>
        public string Content { get; set; }
        /// <summary>
        /// 月销量
        /// </summary>
        public int MonthSale { get; set; }
        /// <summary>
        /// 总销量
        /// </summary>
        public int TotalSale { get; set; }
        /// <summary>
        /// 发货地
        /// </summary>
        [MaxLength(50)]
        public string Shipments { get; set; }
        /// <summary>
        /// 图片（以,分割）
        /// </summary>
        public string Pictures { get; set; }
        /// <summary>
        /// 店铺id
        /// </summary>
        public int StoreId { get; set; }

        /// <summary>
        ///分红id
        /// </summary>
        public long? DividendId { get; set; }
        /// <summary>
        /// 最低原价（根据规格设定）
        /// </summary>
        public decimal OriginalPrice { get; set; }
        /// <summary>
        /// 最低价格（根据规格设定）
        /// </summary>
        public decimal Price { get; set; }
        /// <summary>
        /// 钻石会员价格（根据规格设定）
        /// </summary>
        public decimal SuperVipPrice { get; set; }
        /// <summary>
        /// 会员价格（根据规格设定）
        /// </summary>
        public decimal VipPrice { get; set; }
        /// <summary>
        /// 团购价格（根据规格设定）
        /// </summary>
        public decimal GroupPrice { get; set; }
        /// <summary>
        /// 限时购价格（根据规格设定）
        /// </summary>
        public decimal LimitPrice { get; set; }
        /// <summary>
        /// 限时购标识
        /// </summary>
        public bool IsTimeLimit { get; set; }
        /// <summary>
        /// 限时购开始时间
        /// </summary>
        public DateTime? LimitBeginTime { get; set; }
        /// <summary>
        /// 限时购结束时间
        /// </summary>
        public DateTime? LimitEndTime { get; set; }
        /// <summary>
        /// 砍价开始时间
        /// </summary>
        public DateTime? BargarinBeginTime { get; set; }
        /// <summary>
        /// 砍价结束时间
        /// </summary>
        public DateTime? BargarinEndTime { get; set; }

        /// <summary>
        /// 其他说明
        /// </summary>
        public string Discription { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }
        /// <summary>
        /// 保持零售价标识
        /// </summary>
        public bool IsKeepPrice { get; set; }
        /// <summary>
        /// 安装费用
        /// </summary>
        public decimal PerPrice { get; set; }
        /// <summary>
        /// 是否批发
        /// </summary>
        public bool IsWholesale { get; set; }
        /// <summary>
        /// 最低批发件数
        /// </summary>
        public int MinWholesale { get; set; }
        /// <summary>
        /// 是否置顶
        /// </summary>
        public bool IsPop { get; set; }
        /// <summary>
        /// 首页标签
        /// </summary>
        public string MainTags { get; set; }
        /// <summary>
        /// 砍价底价
        /// </summary>
        public decimal BargainPrice { get; set; }
        /// <summary>
        /// 需砍价次数
        /// </summary>
        public int BargainTimes { get; set; }
        /// <summary>
        /// 是否砍价
        /// </summary>
        public bool IsBargain { get; set; }
        /// <summary>
        /// 果树总数量
        /// </summary>
        public int? TreeTotalQty { get; set; }

        /// <summary>
        /// 果树剩余数量
        /// </summary>
        public int? TreeRemainingQty { get; set; }
        /// <summary>
        /// 分红期数
        /// </summary>
        public int? NumberPeriods { get; set; }

        /// <summary>
        /// 期限（月）
        /// </summary>
        public int? Timelimit { get; set; }

        /// <summary>
        /// 分红比例
        /// </summary>
        public decimal? DividendAmount { get; set; }
        /// <summary>
        /// 分红类型
        /// </summary>
        public DividendType? DividendTypes { get; set; }

        /// <summary>
        /// 商品类型
        /// </summary>
        public ItemsType? ItemType { get; set; }
        /// <summary>
        /// 保底水果公斤数
        /// </summary>
        public int LatestFruitAmount { get; set; }
        /// <summary>
        /// 保底水果名称
        /// </summary>
        public string LatestFruitName { get; set; }
        /// <summary>
        /// 对应果树所在地址
        /// </summary>
        public string TreeAddress { get; set; }
        /// <summary>
        /// 对应最小果树号
        /// </summary>
        public string MinTreeNumber{ get; set; }
        /// <summary>
        /// 对应最大果树号
        /// </summary>
        public string MaxTreeNumber { get; set; }
        /// <summary>
        /// 对应果树颗数
        /// </summary>
        public int TreeCount { get; set; }
        /// <summary>
        /// 果树剩余颗数
        /// </summary>
        public int LeftTreeCount { get; set; }
        /// <summary>
        /// 果树成熟时间
        /// </summary>
        public DateTime? FruitFinishTime { get; set; }
        /// <summary>
        /// 购买获得体验金
        /// </summary>
        public decimal Points { get; set; }
        /// <summary>
        /// 是否释放体验金
        /// </summary>
        public bool IsReleasePoints { get; set; }
        /// <summary>
        /// 释放体验金模板Id
        /// </summary>
        public long ReleasePointId { get; set; }
        /// <summary>
        /// 是否已售完
        /// </summary>
        public bool IsSaleOut { get; set; }
        /// <summary>
        /// 分红商品状态
        /// </summary>
        public enum DividendStatus : int
        {
            /// <summary>
            ///未开始分红
            /// </summary>
            [Description("未开始分红")]
            Start = 0,

            /// <summary>
            /// 分红中
            /// </summary>
            [Description("分红中")]
            Ongoing = 1,

            /// <summary>
            /// 分红完成
            /// </summary>
            [Description("分红完成")]
            End = 2,
        }


        /// <summary>
        /// 商品类型
        /// </summary>
        public enum ItemsType : int
        {
            /// <summary>
            /// 商城商品
            /// </summary>
            [Description("商城商品")]
            ShoppingItems = 0,

            /// <summary>
            /// 理财商品
            /// </summary>
            [Description("理财商品")]
            DividendItems = 1,
        }
    }
}
